package com.hspedu.homework;

import java.util.*;

/**
 * @Author Stringzhua
 * @Date 2024/3/13 19:27
 * description:
 */
@SuppressWarnings("all")
public class homework03 {
    public static void main(String[] args) {
        Map m = new HashMap();
        m.put("jack", 650);//int-->Integer
        m.put("tom", 1200);
        m.put("simth", 2900);
        System.out.println("m = " + m);

        //将jack的工资更改为2600
        m.put("jack", 2600);
        System.out.println("m = " + m);

        //为所有员工加薪100
        //遍历--KeySet
        Set keySet = m.keySet();
        for (Object key : keySet) {
            //更新
            m.put(key, (Integer) m.get(key) + 100);
        }
        System.out.println("keySet = " + keySet);

//        //遍历--EntrySet
//        Set entrySet = m.entrySet();
//        for (Object entry : entrySet) {
//            Map.Entry map = (Map.Entry) entry;
//            //更新
//            System.out.println(map.getKey() + "-" + ((Integer)map.getValue()+100));
//        }

        //遍历集合中所有的员工
        Set entrySet1 = m.entrySet();
        //迭代器
        Iterator iterator = entrySet1.iterator();
        while (iterator.hasNext()) {
            Map.Entry entry= (Map.Entry) iterator.next();
            System.out.println("entry = " + entry.getKey());
        }
        //遍历集合中所有的工资
        Collection values = m.values();
        for (Object value :values) {
            System.out.println("工资 = " + value);
        }


    }
}